
package com.scs.application.modules.upms.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scs.application.core.model.CommonResult;
import com.scs.application.core.model.PageResult;
import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.core.serial.SerialRule;
import com.scs.application.modules.upms.request.SerialRuleQueryRequest;
import com.scs.application.modules.upms.service.SerialRuleService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 编号规则 controller
 */
@AllArgsConstructor
@RestController
@RequestMapping("/upms/serial_rules")
public class SerialRuleController extends CrudController<SerialRule, String, SerialRuleService> {

    private SerialRuleService serialRuleService;


    @GetMapping("/page")
    public PageResult page(SerialRuleQueryRequest request) {
        IPage page = serialRuleService.page(request);
        return PageResult.ok("查询成功", page.getRecords(), page.getTotal());
    }

//    @GetMapping("/list")
//    public CommonResult list(SerialRuleQueryRequest request) {
//        List<SerialRule> list = SerialUtils.list();
//        return CommonResult.ok("查询成功", list);
//    }

    /**
     * 同步到缓存
     * @return
     */
    @PostMapping("sync_to_cache")
    public CommonResult syncToCache() {
        service.syncToCache();
        return CommonResult.ok("同步成功");
    }


}
